package com.central.apps.controller;

import com.central.app.service.HandlerService;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BarCodeController {
    @Autowired
    private HandlerService handlerService;

    @PostMapping("/updatePrint")
    public String updatePrint(String ids) throws Exception {
        JSONObject json = new JSONObject();
        json.put("code", "0");

        if (StringUtils.isEmpty(ids)) {
            json.put("msg", "请选择需要更新的条码数据!");
            return json.toString();
        }

        // 更新条码数据打印信息
        handlerService.updateBySql("update gq_barcode set isprint = '是' where id in (" + ids + ")");

        json.put("msg", "更新条码数据打印信息成功!");
        return json.toString();
    }
}
